import br.com.decsoft.lv.events.*;
import br.com.decsoft.lv.itemRenderers.*;
import br.com.decsoft.lv.model.*;

import flash.events.Event;

import mx.controls.Alert;
import mx.core.Application;
import mx.rpc.events.FaultEvent;

private function init():void {
	addEventListener("removeItemCart", removeItemCarrinho);
}

private function onFaultHandler(event:FaultEvent):void {
	Alert.show("Erro na aplicação: \n\n" + event.fault.message);
}

public function insereItemCarrinho(carrinho: Carrinho):void {
	Application.application.dataSetCarrinho.addItem(carrinho);
}

public function removeItemCarrinho(e:Event):void {
	Application.application.dataSetCarrinho.removeItemAt(tlItenCart.selectedIndex);
}

private function btnContinuarClick():void {
	Application.application.currentState = "main";
}

private function btnLimparCarrinhoClick():void {
	Application.application.dataSetCarrinho.removeAll();	
}